
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layuiadmin/layui-v2.5.5/layui/css/layui.css" media="all" type="text/css">
</head>
<script type="text/javascript" src="../../layuiadmin/lib/jquery.min.js"></script>
<script>
    var data=parent.PartitionId;
    $(function(){
        $("#empName").val(data.empName);
        $("#empId").val(data.empId);
        $("#date").val(data.empBirthdate);
        $("#empSex").val(data.empSex);
        $("#hrIdent").val(data.hrIdent);
        $("#empPapersnum").val(data.empPapersnum);
        $("#hrIdent").val(data.hrIdent);
        $("#empEntrancenum").val(data .empEntrancenum);
        $("#empPracnum").val(data .empPracnum);
        $("#date1").val(data .empPracdate);
        $("#empPracsite").val(data .empPracsite);
        $("#empCertifynum").val(data .empCertifynum);
        $("#empGainsite").val(data .empGainsite);
        $("#empIntroduce").val(data .empIntroduce);
        $("#empSocialNum").val(data .empSocialNum);
        $("#date3").val(data .empContStartdate);
        $("#date2").val(data .empEntryDate);
        $("#date4").val(data .empContEnddate);
        $("#empPhone").val(data .empPhone);
        $("#empSite").val(data .empSite);
        $("#empContactPhone").val(data .empContactPhone);
        $("#empEmail").val(data .empEmail);
        $("#empPostcode").val(data .empPostcode);
        $("#empQq").val(data .empQq);
        $("#empWechat").val(data .empWechat);
        var  empSex=data .empSex;
        var empWorkstatus=data .empWorkstatus;
        var empInsured=data .empInsured;
        if(empSex.valueOf()=='男'){
            $("#empSex").attr("checked",true);
        }else{
            $("#empSex1").attr("checked",true);
        }
        if(empWorkstatus.valueOf()=='在职'){
            $("#empWorkstatus").attr("checked",true);
        }else{
            $("#empWorkstatus1").attr("checked",true);
        }
        if(empInsured.valueOf()=='是'){
            $("#empInsured").attr("checked",true);
        }else{
            $("#empInsured1").attr("checked",true);
        }


    })  ;
</script>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>基本信息</legend>
</fieldset>
<form class="layui-form" action="" lay-filter="example" >
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input name="empId" id="empId" type="hidden">
            <input name="empName" id="empName" class="layui-input" type="text"  placeholder="请输入姓名" autocomplete="off" readonly="readonly"  >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出生日期</label>
        <div class="layui-input-inline">
            <input name="empBirthdate"  class="layui-input" id="date" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date" readonly="readonly" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="empSex" title="男" id="empSex" value="男" readonly="readonly" >
            <input type="radio" name="empSex" title="女" id="empSex1"  value="女" readonly="readonly"  >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否在职</label>
        <div class="layui-input-block">
            <input name="empWorkstatus" id="empWorkstatus" title="在职" type="radio"  value="在职">
            <input name="empWorkstatus" id="empWorkstatus1"  title="离职" type="radio"  value="离职">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">证件类型</label>
        <div class="layui-input-block">
            <select name="hrIdent" id="hrIdent1" Readonly="true" lay-filter="aihao" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">证件号</label>
        <div class="layui-input-block">
            <input name="empPapersnum" id="empPapersnum" Readonly="true" class="layui-input" type="text" placeholder="请输入证件号" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最高学历</label>
        <div class="layui-input-block">
            <select name="empHigthEducation" lay-filter="aihao" Readonly="true" id="education" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最高学位</label>
        <div class="layui-input-block">
            <select name="empHigthDegree" lay-filter="aihao" Readonly="true" id="degree" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所内身份</label>
        <div class="layui-input-block">
            <select name="empPosition" lay-filter="aihao" Readonly="true" id="empPosition" lay-verify="title1" >
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名族</label>
        <div class="layui-input-block">
            <select name="hrNation" lay-filter="aihao" Readonly="true" id="hrNation" lay-verify="title1" >
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">政治面貌</label>
        <div class="layui-input-block">
            <select name="hrPolitical" lay-filter="aihao" Readonly="true" id="hrPolitical" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">婚姻状况</label>
        <div class="layui-input-block">
            <select name="empMaritalsta" lay-filter="aihao" Readonly="true" id="empMaritalsta" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">门禁号</label>
        <div class="layui-input-block">
            <input name="empEntrancenum" id="empEntrancenum" Readonly="true" class="layui-input" type="text" placeholder="请输入门禁号" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">专业部</label>
        <div class="layui-input-block">
            <select name="hrSpecialty" lay-filter="aihao" Readonly="true" id="hrSpecialty" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
        <legend>从业资料</legend>
    </fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">执业类别</label>
        <div class="layui-input-block">
            <select name="hrPractise" lay-filter="aihao" Readonly="true" id="hrPractise" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职业证号码</label>
        <div class="layui-input-block">
            <input name="empPracnum" id="empPracnum" Readonly="true" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">首职业时间</label>
        <div class="layui-input-inline">
            <input name="empPracdate"  class="layui-input" Readonly="true" id="date1" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">首次职业地</label>
        <div class="layui-input-block">
            <input name="empPracsite" id="empPracsite" Readonly="true" class="layui-input" type="text" placeholder="请输入地点" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资格证类别</label>
        <div class="layui-input-block">
            <select name="hrCertify" lay-filter="aihao" Readonly="true" id="hrCertify" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资格证号码</label>
        <div class="layui-input-block">
            <input name="empCertifynum" id="empCertifynum" Readonly="true" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资格证考取方式</label>
        <div class="layui-input-block">
            <select name="empGainway" lay-filter="aihao" Readonly="true" id="empGainway" lay-verify="title1">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资格证考取地</label>
        <div class="layui-input-block">
            <input name="empGainsite" id="empGainsite" Readonly="true" class="layui-input" type="text" placeholder="请输入地点" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">个人介绍</label>
        <div class="layui-input-block">
            <textarea name="empIntroduce" id="empIntroduce" Readonly="true" class="layui-textarea" placeholder="请输入内容"></textarea>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
        <legend>入职情况</legend>
    </fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">入职日期</label>
        <div class="layui-input-inline">
            <input name="empEntryDate"  class="layui-input" Readonly="true" id="date2" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">社保号码</label>
        <div class="layui-input-block">
            <input name="empSocialNum" id="empSocialNum" Readonly="true" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">合同开始</label>
        <div class="layui-input-inline">
            <input name="empContStartdate"  class="layui-input" Readonly="true" id="date3" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">合同截止</label>
        <div class="layui-input-inline">
            <input name="empContEnddate"  class="layui-input" Readonly="true" id="date4" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否参保</label>
        <div class="layui-input-block">
            <input name="empInsured" id="empInsured" title="是" type="radio"  value="是">
            <input name="empInsured" id="empInsured1" title="否" type="radio" value="否">
            <button class="layui-btn" id="test1" type="button">员工头像</button>
            <div class="layui-upload-list">
                <img class="layui-upload-img" id="demo1">
                <p id="demoText"></p>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>联系信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="empPhone" id="empPhone" Readonly="true" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系地址</label>
            <div class="layui-input-block">
                <input name="empSite" id="empSite" Readonly="true" class="layui-input" type="text" placeholder="请填写地址" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input name="empContactPhone" Readonly="true" id="empContactPhone" class="layui-input" type="text" placeholder="请输入电话" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input name="empEmail" id="empEmail" Readonly="true" class="layui-input" type="text" placeholder="请填写邮箱" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮政编码</label>
            <div class="layui-input-block">
                <input name="empPostcode" Readonly="true" id="empPostcode" class="layui-input" type="text" placeholder="请填写邮政编码" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">QQ</label>
            <div class="layui-input-block">
                <input name="empQq" id="empQq" Readonly="true" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">微信</label>
            <div class="layui-input-block">
                <input name="empWechat"  Readonly="true" id="empWechat" class="layui-input" type="text" placeholder="请输入号码" autocomplete="off" lay-verify="title">
            </div>
        </div>
        <div class="layui-form-item">
        </div>
</form>
<script src="../../layuiadmin/layui-v2.5.5/layui/layui.js" type="text/javascript"></script>
<script type="text/javascript" src="../../layuiadmin/lib/jquery.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#date2'
        });
        laydate.render({
            elem: '#date3'
        });
        laydate.render({
            elem: '#date4'
        });
                    $('#test1').on('click', function(){
                        window.PartitionId=data;
                        layer.open({
                            type: 2,
                            title: '员工头像',
                            maxmin: true,
                            shadeClose: true, //点击遮罩关闭层
                            area : ['400px' , '400px'],
                            content: 'Hrimg.html'
                        });
                    });
        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请输入';
                }
            }
            ,title1: function(value){
                if(value.length < 1){
                    return '请选择';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });
        //证件类型
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/certificate.json",
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrIdent1').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        })
        var empId=data .empId;
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrIdent1 option").each(function(){
                if(msg.hrIdent==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //最高学历
        $(function(){
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/HrEmp/education",
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#education').append("<option value="+item.educationName+">"+item.educationName+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        })
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#education option").each(function(){
                if(msg.empHigthEducation==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //最高学位
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/degree.json",
                data:{name:name},
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#degree').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        })
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#degree option").each(function(){
                if(msg.empHigthDegree==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //身份
        $(function(){
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/HrEmp/position",
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#empPosition').append("<option value="+item.hrPositionName+">"+item.hrPositionName+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#empPosition option").each(function(){
                if(msg.empPosition==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //名族
        $(function(){
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/HrEmp/nation",
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrNation').append("<option value="+item.nationName+">"+item.nationName+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrNation option").each(function(){
                if(msg.hrNation==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //政治面貌
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/politics.json",
                data:{name:name},
                async: false,
                datatype:"json",
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrPolitical').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrPolitical option").each(function(){
                if(msg.hrPolitical==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //婚姻状况
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/marriage.json",
                data:{name:name},
                async: false,
                datatype:"json",
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#empMaritalsta').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#empMaritalsta option").each(function(){
                if(msg.empMaritalsta==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //专业部
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/technical.json",
                data:{name:name},
                async: false,
                datatype:"json",
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrSpecialty').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrSpecialty option").each(function(){
                if(msg.hrSpecialty==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //职业类别
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/operation.json",
                data:{name:name},
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrPractise').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrPractise option").each(function(){
                if(msg.hrPractise==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //资格证类别
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/hrCertify.json",
                data:{name:name},
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#hrCertify').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#hrCertify option").each(function(){
                if(msg.hrCertify==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //资格证考取方式
        $(function(){
            $.ajax({
                type:"POST",
                url:"../../views/hr/json/empGainway.json",
                data:{name:name},
                datatype:"json",
                async: false,
                success:function(data){
                    $.each(data,function (index,item) {
                        $('#empGainway').append("<option value="+item.id+">"+item.id+"</option>");
                    })
                    layui.form.render("select");
                },error:function(){
                    alert("失败")
                }
            })
        });
        $.post("http://localhost:8080/HrEmp/getByid",{"empId":empId},function(msg){
            $("#empGainway option").each(function(){
                if(msg.empGainway==$(this).val()){
                    $(this).attr("selected","selected")
                }
            });
            layui.form.render("select");
        });
        //监听提交
        form.on('submit(demo1)', function(data){
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/HrEmp/update",
                data:data.field,
                datatype:"json",
                async:true,
                success:function(data){
                    layer.alert('修改成功',function(){
                        parent.layer.closeAll();
                    })
                    parent.layui.table.reload('listData')
                },error:function(){
                    alert("失败")
                }
            });
            return false;
            /*            layer.alert(JSON.stringify(data.field), {

                            title: '最终的提交信息'
                        })
                        return false;*/
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function(){
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

    });
</script>

</body>
</html>